import { pget, ppostJson, ppost } from '@/utils/req'
import { modalApi } from '@/utils/modalReq'

// 渠道规则列表
export function getChannelinnovationrewardsList(query: any) {
	return pget(`${modalApi.sales}/sale/channelinnovationrewards/page`, query)
}

// 获取一级渠道类型
export function getFirstChannelType() {
	return pget(`${modalApi.sales}/sale/clue/getFirstChannelType`)
}
// 获取二级渠道类型
export function getSecondChannelType(query: any) {
	return pget(`${modalApi.sales}/sale/clue/getSecondChannelType`, query)
}

// 获取渠道奖励编号
export function createNoc() {
	return pget(`${modalApi.sales}/sale/channelinnovationrewards/createNo`)
}


// 商品方案列表
export function getCommodityData(query: any) {
	return pget(
		`${modalApi.sales}/sale/channelinnovationrewards/commodityData`,
		query,
	)
}

// 新增
export function saveSubmitFlow(query: any) {
	return ppostJson(
		`${modalApi.sales}/sale/channelinnovationrewards/submitFlow`,
		query,
	)
}

// 修改
export function updateSubmitFlow(query: any) {
	return ppostJson(
		`${modalApi.sales}/sale/channelinnovationrewards/relaunchFlow`,
		query,
	)
}

// 详情
export function channelinnovationrewardsDetail(query: any) {
	return pget(`${modalApi.sales}/sale/channelinnovationrewards/detail`, query)
}

// 商品方案详情
export function commodityDetail(query: any) {
	return pget(
		`${modalApi.sales}/sale/channelinnovationrewards/commodityDetail`,
		query,
	)
}

// 删除
export function removeSubmitFlow(query: any) {
	return ppost(
		`${modalApi.sales}/sale/channelinnovationrewards/remove`,
		query,
	)
}

// 修改状态
export function updateStatus(query: any) {
	return pget(
		`${modalApi.sales}/sale/channelinnovationrewards/updateStatus`,
		query,
	)
}

// 审核
export function auditFlow(query: any) {
	return ppostJson(
		`${modalApi.sales}/sale/channelinnovationrewards/auditFlow`,
		query,
	)
}

// 获取车队队长名称
export function getFleetName() {
	return pget(
		`${modalApi.sales}/sale/channelinnovationrewards/getFleetName`,
	)
}
// 线索分配
export function clueAllot(query: any) {
	return pget(
		`${modalApi.sales}/sale/clue/allot`,
		query,
	)
}

// 线索编码

export function createNoC() {
	return pget(
		`${modalApi.sales}/sale/clue/createNo`,
	)
}

// 渠道拉新奖励规则历史记录

export function getHistory(query: any) {
	return pget(
		`${modalApi.sales}/sale/channelinnovationrewards/processList?id=${query}`,
	)
}

/**
 * 反查关联的渠道奖励
 * @param params
 * @returns
 */
export async function channelOnlyCode(params?: any): Promise<any> {
	return ppostJson(
		`${modalApi.sales}/sale/channelinnovationrewards/getCommodityTypeNo`,
		params
	)
}
